<?php

use think\exception\HttpResponseException;


function throw_validate_error($condition, $message)
{
    if ($condition) {
        $result = [
            'msg' => $message,
            'code' => 0,
            'time' => time(),
            'data' => null
        ];
        $header['statuscode'] = 200;

        $response = \think\Response::create($result, 'json', 200)->header($header);
        //halt($response);
        throw new think\exception\HttpResponseException($response);
    }
}


function request_page(\think\Request $request)
{
    $page = $request->param('page');
    if (!$page || $page < 1 || !is_numeric($page)) {
        return 1;
    }
    return $page;
}
